// pages/orderdelivery/orderdelivery.js
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgurl:app.globalData.Imageurl,
    consigneeName:'',
    consigneeMobile:'',
    consigneeAddress:'',
    setaddr:false,
    isloadcomplete:true,

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getGoodsOrderDetails(options.orderId)
  },

  godetails(e){
    console.log(e)
    wx.navigateTo({
      url: '/pages/details/details?goodsid='+e.currentTarget.dataset.goodsid,
    })
  },
  //联系客服
  handleContact (e) {
    console.log(e.detail.path)
    console.log(e.detail.query)
  },
  getGoodsOrderDetails(id){
    var t=this
    wx.request({
      url: app.globalData.Interfaceurl + 'getGoodsOrderDetails',
      method: "post",
      header: {
          "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
          userId: app.globalData.userId,
          orderId:id
      },
      success: res => {
          console.log(res)
        
          t.setData({
            goods:res.data.goodsOrder,
            consigneeAddress:res.data.goodsOrder.consigneeAddress,
            consigneeMobile:res.data.goodsOrder.consigneeMobile,
            consigneeName:res.data.goodsOrder.consigneeName,
            isloadcomplete:false,

          })
          console.log(t.data.goods)
          // if (myorderStats==''&&mypayStats=='') {
            
    
          // }
          
          
          
      }
  })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let pages = getCurrentPages();

     let currPage = pages[pages.length - 1];

        console.log(this.data.consigneeName)    //在这里已经发生改变了
        console.log(this.data.consigneeMobile)
        console.log(this.data.consigneeAddress)
        if (this.data.setaddr) {
          console.log('更改')
        }

  },
  //
  setaddress(){
    this.setData({
      setaddr:true
    })
    wx.navigateTo({
      url: '/pages/addressmg/addressmg',
    })
  },
  goaftersale(e){
    var t=this
    // console.log(e)
    wx.showModal({
      title: '提示',
      content: '您将申请该订单退款',
      success (res) {
        if (res.confirm) {

          wx.request({
            url: app.globalData.Interfaceurl + 'applyGoodsOrderRefund',
            method: "post",
            header: {
                "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
            },
            data: {
                userId: app.globalData.userId,
                orderId:e.currentTarget.dataset.id
            },
            success: res => {
                console.log(res)
                wx.switchTab({
                  url: '/pages/my/my',
                })
            }
        })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})